@section('title')
    我的帖子 @parent
@show

@section('subcontent')

<!-- 我发布的帖子 -->
<?php

 if(isset($data)){
 	$id = $data['id'];
 	$workscopes = $data['workscopes'];
	$articleClasss = $data['articleClasss'];
}else{
	$data['class']=368;
	$data['law_cat']=303;
	$data['visibility']=0;
}
?>
<div id="mainUserInfo">
<div class="mod-main mod-comm lefta-box">
    <div class="mt">
		<h3 class="curr">@if(isset($data['id']))编辑帖子@else发布新帖@endif</h3>
    </div>
    <div class="mc">
    	<div class="user-set userset-lcol">
		    <div class="form">
		    	<form id="blog_form" name="form" action="{{ route('center.lawyer.blog.create') }}" method="post" enctype="multipart/form-data">
		        <div class="form-item">
		            <span class="label">
		                文章标题：
		            </span>
		            <div class="fl">
		                <input  type="text" class="itxt itxt1" maxlength="20" id="title" name="title" value="{{$data['title'] or '' }}">
		            </div>
		        </div>
		        <div class="form-item">
		            <span class="label">
		                文章类型：
		            </span>
		            <div class="fl">
		                <select name="class" class="selt mr5" id="category">
		                    <option value="368" {{($data['class']==368)? 'selected':''}}>
						资讯			
		                    </option>
		                    <option value="369" {{($data['class']==369)? 'selected':''}} >
						知识			
		                    </option>		                    
		                    <option value="370" {{($data['class']==370)? 'selected':''}} >
						案例		
		                    </option>	                    		                    		                     -->
		                </select>
		            </div>
		        </div>
		        <div class="form-item">
		            <span class="label">
		                法律类型：
		            </span>
		            <div class="fl">
		                <select name="law_cat" class="selt mr5" id="law_cat" value="19">
		                	<?php
		                	foreach($workscopes as $key => $workscope) {
		                	?>
			                    <option value="{{$workscope['key']}}" {{($data['law_cat']==$key)? 'selected':''}}>
			                        {{$workscope['value']}}
			                    </option>
		                	<?php
		                	}
		                	?>
		                </select>
		            </div>
		        </div>
		        <div class="form-item">
		            <span class="label">
		              	文章简介：
		            </span>
		            <div class="fl">
						<textarea class="itxt itxt1" maxlength="140" id="info" name="info" value="" style="width:600px;height:100px;">{{ $data['info'] or '' }}</textarea>
		            	
		            </div>
		        </div>
		        <div class="form-item">
					<span class="label">文章正文： </span>
					<div class="fl" style="width:660px;">
		            	<textarea cols="80" rows="10" name="content" id="article_content" style="visibility: hidden; display: none;width:600px;height:400px;" class="form-control">{{ $data['content'] or '' }}</textarea>
			     		
			     	</div>
			     	
			     </div>

		        <div class="form-item">
		            <span class="label">
		                查看权限：
		            </span>
		            <div class="fl">
		                <input type="radio" name="visibility" class="lvradio" {{($data['visibility']==0)? 'checked':''}}  value="0">
		                <label class="mr10">
		                    所有人
		                </label>
		                <input type="radio" name="visibility" class="lvradio" {{($data['visibility']==1)? 'checked':''}}  value="1">
		                <label class="mr10">
		                   关注我的人
		                </label>
		                <input type="radio" name="visibility" class="lvradio" {{($data['visibility']==2)? 'checked':''}} value="2">
		                <label class="mr10">
		                   私人文章
		                </label>
		            </div>
		        </div>
		        <div class="form-item">
		            <span class="label">
		            
		                &nbsp;
		            </span>
		            <div class="fl">
					<label class="mr10">	文章缩略图：</label><input type='file' name ="img"><br>
					@if(isset($data['img']))
					<img src="{{ Config::get('app.url') }}/{{ $data['img'] }}" style="width:200px;">
					@endif	 
		            <br><br>					           
		            <input type="hidden" name="file_img" value="{{ $data['img'] or ''}}" />
		            <input type="hidden" name="id" value="{{ $id or '' }}" />
		            <input type="hidden" name="_token" value="{{ csrf_token() }}" />            	            
					<input type="hidden" name="status" id="statusName" value="0">

					<input type="submit" id="depositDrafts" class="btn-5 inpbg" value=" 保存草稿">
	                <input type="submit" id="publishArticle" class="btn-5 inpbg" value=" 发布文章">
			                
		            </div>
		        </div>
		        </form>
		    </div>
		</div>
    </div>
</div>
</div>
<!--这里引用jquery和wangEditor.js-->

{{ HTML::script('js/kindeditor4/kindeditor-min.js') }}
{{ HTML::script('js/kindeditor4/lang/zh_CN.js') }}
{{ HTML::script("/ckeditor/ckeditor.js") }}
<script>
$(function() {
	CKEDITOR.replace('article_content'	, {
		height: 250,
		extraPlugins: 'colorbutton,colordialog',
		filebrowserBrowseUrl : '/ckfinder/ckfinder.html',
		filebrowserImageBrowseUrl : '/ckfinder/ckfinder.html?Type=Images',
		filebrowserFlashBrowseUrl : '/ckfinder/ckfinder.html?Type=Flash',
		filebrowserUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
		filebrowserImageUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
		filebrowserFlashUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
	});
});

</script>

<script type="text/javascript">
	var crete_url = "{{route('center.lawyer.blog.create')}}";
	var draft_url = "{{ route('center.lawyer.blog.draft') }}";
	var list_url = "{{ route('center.lawyer.blog.list') }}";

	var oName = document.getElementById("statusName");
	var oBtnDeposit = document.getElementById("depositDrafts");
	var oBtnPublish = document.getElementById("publishArticle");
	oBtnDeposit.onclick =function(){
		
		if(check()){
			oName.value ="2";
 			document.form.submit();
		}else{
			return false;
		}
 	}
 	oBtnPublish.onclick =function(){
 		
 		if(check()){
 			oName.value ="0";
 			document.form.submit();
		}else{
			return false;
		}
 	}		

 	function check(){
 		var editorText = $("#cke_article_content").find("iframe").contents().find("body");
		var contents = editorText.html();
	 	var parm = getParams("#blog_form");
	 	if(!parm.title){
	 		layer.msg("标题不能为空");
	 		return false;
	 	}
	 	if(!parm.info){
	 		layer.msg("简介不能为空");
	 		return false;
	 	}
	 	if(content.length<20){
	 		layer.msg("内容不能为空或小于20个字");
	 		return false;
	 	}
	 	return true;
	}

</script>
@show